package com.qf.dao;

import com.qf.entity.LoginHistory;
import com.qf.util.JdbcUtils;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.Connection;
import java.sql.Date;
import java.sql.SQLException;

/**
 * @author zdl
 * @date 2025/1/19
 */
public class LoginHistoryDao {
    public void addLoginHistory(LoginHistory history){
        Connection conn = JdbcUtils.getConnection();
        QueryRunner qr = new QueryRunner();
        String sql = "insert into tb_login_history (user_id,ip,create_time) values (?,?,?)";
        try {
            qr.update(conn,sql,history.getUserId(),history.getIp(),new Date(history.getCreateTime().getTime()));
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

    }
}
